<script setup lang="ts">
import { watch, ref } from "vue";
const
  props = defineProps({
    modelValue: { type: String, },
    disabled: { type: Boolean, default: false }
  }),
  page = ref<gt.PageData<gt.sql.stockLog>>({ current: 1, size: 10, total: 0, data: [] });
async function init() {
  page.value = props.modelValue ? await gd.stockLog.read({
    "#page": { current: page.value.current, size: page.value.size },
    stock: props.modelValue
  }) : { current: 1, size: 10, total: 0, data: [] };
}
watch(() => props, init, { deep: true, immediate: true });

defineExpose({
  validate() {
    return new Promise<boolean>((resolve) => {
      resolve(true);
    });
  },
  resetFields() { }
});
</script>
<template>
  <div class="stockLog">
    <el-table stripe highlight-current-row :data="page.data" class="wf fg1" type="expand" row-key="id" height="20em">
      <el-table-column prop="id" label="id" width="100" show-overflow-tooltip />
      <el-table-column prop="_createTime" label="创建时间" width="120" show-overflow-tooltip />
      <el-table-column prop="_user.name" label="操作人" width="80" show-overflow-tooltip />
      <el-table-column prop="sum" label="数量" width="80" show-overflow-tooltip />
      <el-table-column prop="des" label="备注" show-overflow-tooltip min-width="200" />
    </el-table>
    <el-pagination background layout="prev, pager, next, jumper, ->, sizes, total"
      :page-sizes="[10, 20, 30, 40, 50, 100]" v-model:page-size="page.size" :total="page.total"
      v-model:currentPage="page.current" @size-change="init" @current-change="init" />

  </div>
</template>
<style lang="scss" scoped>
.stockLog {
  position: relative;
  >:not(.wf) {
    width: 49%;
  }
}
</style>